package com.pets.controller;


import com.pets.entity.Scoring;
import com.pets.entity.Users;
import com.pets.service.IScoringService;
import com.pets.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * <p>
 * 打分表 前端控制器
 * </p>
 *
 * @author 啦啦啦
 * @since 2024-04-09
 */
@RestController
@RequestMapping("/scoring")
@Api(tags = "打分表接口")
public class ScoringController {

    @Autowired
    private IScoringService scoringService;

    @ApiOperation("创建打分记录（只需要传递两个字段文件id-> fileId,和打分的分数-> fraction）")
    @PostMapping
    public Result register(@RequestBody Scoring scoring,HttpSession session) {
        /*Object userObject = session.getAttribute("users");
        if (userObject instanceof Users) {
            Users user = (Users) userObject;
            System.out.println(user.getUsername()+"/"+user.getUserId());
            scoring.setUserId(user.getUserId());
            return scoringService.register(scoring);
        }else {
            return Result.fail("未登录！");
        }*/

        return scoringService.register(scoring);
    }

}
